package de.hmm.hwip.general;

import java.net.Socket;
import java.util.Map;

import org.json.JSONObject;
import org.osgi.framework.BundleContext;

import android.database.Cursor;

/**
 * Interface for classes of Messagehandler units
 * 
 * @author Johannes Mendel
 * @version 26.09.2012
 *
 */
public interface IMessageContent extends Runnable {
	
	/**
	 * setter for the OSGi bundle context
	 * 
	 * @param inputContext - current bundle context
	 */
	public void setBundleContext (BundleContext inputContext);
	
	/**
	 * setting the payload data
	 * 
	 * @param payload - Json-data
	 */
	public void setPayload(JSONObject paylaod);
	
	/**
	 * setter for Network connection data 
	 * 
	 * @param connection
	 */
	public void setConnection(Socket connection);
	
	/**
	 * 	stop the waiting condition for messagenhandler
	 */
	public void stopWaiting();
	
	/**
	 * setting flag, if a decrypted answer is generated
	 * 
	 * @param flag
	 */
	public void setSecurityFlag(boolean flag);
	
	/**
	 * answer the the end-device
	 */
	public void answerReceiver();
	
	/**
	 * setter for the result of select-query
	 * 
	 * @param result - result of select query
	 */
	public void setQueryResult(Cursor result);
	
	/**
	 * setter for the result of an insert/select-query
	 * 
	 * @param result - result of insert/select-query
	 */
	public void setQueryResult(int result);
	
	/**
	 * getter for data query
	 * 
	 * @return query
	 */
	public String getQuery();
	
	/**
	 * generate an answer for the request/query in Jsaon
	 * 
	 * @return Json with answer
	 */
	public JSONObject generateAnswer();
	
	/**
	 * set error as result when there is somewhere an error while
	 * connecting or querying the data source
	 */
	public void setErrorResult(String error);
	
	/**
	 * getter for query type
	 * either select or insert/update query
	 * 
	 * @return 1 select, 2 insert/update, 3 delete
	 */
	public int getQueryType();
	
	/**
	 * getter for Map with complete Data Base
	 * is used when complete db is copied 
	 * @return Map<table, Map<column, values[]>>
	 */
	public Map<String, Object> getCompleteDB();
	
	/**
	 * setter for the result of complete DB copy
	 * 
	 * @param dbMap - JSONObject of complete DB
	 */
	public void setCompleteDbResult(JSONObject dbMap);
	
}
